package com.simoniu.mp.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.simoniu.mp.entity.Students;
import com.simoniu.mp.view.StudentsView;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface StudentsMapper extends BaseMapper<Students> {

    @Select("select sid, sname,gender,birthday,school,major,s.cid ,cname from students s inner join class_room c where s.cid=c.cid")
    @Results(
            {
                    @Result(property = "sid", column = "sid"),
                    @Result(property = "sname", column = "sname"),
                    @Result(property = "gender", column = "gender"),
                    @Result(property = "birthday", column = "birthday"),
                    @Result(property = "school", column = "school"),
                    @Result(property = "major", column = "major"),
                    @Result(property = "cid", column = "cid"),
                    @Result(property = "cname", column = "cname")
            }
    )
    List<StudentsView> queryStudentsView();
}
